<?php

namespace App\Traits;

use App\Services\Category\UserLabelCategoryService;

trait LabelTrait
{

    /**
     * 获取标签值
     * @param $scene
     * @param $labelIds
     * @return array
     */
    protected function getLabelList($scene, $labelIds)
    {
        if (!is_array($labelIds)) {
            $labelIds = explode(',', $labelIds);
        }
        if (empty($labelIds)) {
            return [];
        }
        /**
         * @var UserLabelCategoryService $userLabelCategoryService
         */
        $userLabelCategoryService = app()->make(UserLabelCategoryService::class);
        $list = $userLabelCategoryService->getByIds($labelIds);
        return array_column($list, 'name');
    }
}
